<script lang="ts" setup>
import { ID_INJECTION_KEY, ElConfigProvider } from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import { useAppStore } from './stores/app'
import { addVisit } from './api/shop'
import { useThemeStore } from './stores/theme'
import 'element-plus/theme-chalk/dark/css-vars.css'
const router = useRouter()
provide(ID_INJECTION_KEY, {
    prefix: 100,
    current: 0
})
const config = {
    locale: zhCn
}
const appStore = useAppStore()
const themeStore = useThemeStore()
themeStore.getTheme()
const { pcTitle, pcIco, pcKeywords, pcDesc } = appStore.getWebsiteConfig
useHead({
    title: pcTitle,
    meta: [
        { name: 'description', content: pcDesc },
        { name: 'keywords', content: pcKeywords }
    ],
    link: [
        {
            rel: 'icon',
            href: pcIco
        }
    ]
})

const { close, status, url } = appStore.getPcPageConfig
if (status == 0) {
    if (close == 1) { location.href = url }
    if (close == 0) {
        router.replace('/empty')
    }
}
addVisit()
</script>
<template>
    <ElConfigProvider v-bind="config">
        <NuxtLoadingIndicator color="#4a5dff" :height="2" />
        <NuxtPage />
    </ElConfigProvider>
</template>
